﻿@model PagedData<SiteData>

@{
	ViewBag.Title = "Site Index";
}


@using (Html.BeginForm()) {
	@Html.AntiForgeryToken()

	var grid = CarrotWeb.CarrotWebGrid<SiteData>(Model);

	grid.TableAttributes = new { @class = "datatable" };
	grid.THeadAttributes = new { @class = "tablehead" };
	grid.EmptyDataTemplate = @<text><p> <b>No records found.</b> </p></text>;
	grid.ConfigName(Html.NameFor(x => x));

	grid
		.AddColumn(new CarrotGridTemplateColumn<SiteData> {
			HasHeadingText = false,
			FormatTemplate = @<text> @CarrotWeb.ActionImage("SiteDetail", RouteConfig.AdminCtrlr, new { @id = @item.SiteID }, "~/Assets/Admin/Images/application_edit.png", "Edit", null, null) </text>
		})
		.AddColumn(x => x.SiteName, new CarrotGridColumn { Sortable = true })
		.AddColumn(x => x.MainURL, new CarrotGridColumn { Sortable = true })
		.AddColumn(x => x.SiteID, new CarrotGridColumn { Sortable = true })
		.AddColumn(new CarrotGridTemplateColumn<SiteData> {
			HasHeadingText = false,
			FormatTemplate = @<text> @if (item.SiteID == SiteData.CurrentSiteID) {
				<img src="~/Assets/Admin/Images/house.png" alt="Current Site" title="Current Site" />
			}  </text>
		})
		.AddColumn(x => x.BlockIndex, new CarrotGridBooleanImageColumn {
			ImagePathTrue = "~/Assets/Admin/Images/zoom_out.png",
			ImagePathFalse = "~/Assets/Admin/Images/magnifier.png",
			AlternateTextTrue = "Yes",
			AlternateTextFalse = "No",
			Sortable = true
		});

		@grid.Write()
}
